/*
 * @Descripttion: 
 * @version: 
 * @Author: cyj
 * @Date: 2022-12-05 11:45:53
 */
import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // 首页重定向到发现音乐
    {
      path: '/',
      redirect: "/findmusic",
    },
    // 发现音乐
    {
      path: '/findmusic',
      name: 'Findmusic',
      component: () => import('../views/findmusic/Findmusic.vue'),
      redirect: '/findmusic/discover',
      children: [
        {
          path: 'discover',
          name: 'Discover',
          component: () => import('../views/findmusic/discover/Discover.vue')
        },
        {
          path: 'songlist',
          name: 'Songlist',
          component: () => import('../views/findmusic/songlist/Songlist.vue')
        },
        {
          path: 'songrank',
          name: 'Songrank',
          component: () => import('../views/findmusic/songrank/Songrank.vue')
        },
        {
          path: 'singer',
          name: 'Singer',
          component: () => import('../views/findmusic/singer/Singer.vue')
        },
        {
          path: 'newsongs',
          name: 'Newsongs',
          component: () => import('../views/findmusic/newsongs/Newsongs.vue')
        }
      ]
    },
    // 推荐视频
    {
      path: '/recvideo',
      name: 'Recvideo',
      component: () => import('../views/recvideo/Recvideo.vue'),
      redirect: '/recvideo/mv',
      children: [
        {
          path: 'mv',
          name: 'Mv',
          component: () => import('../views/recvideo/children/Mv.vue')
        },
        {
          path: 'video',
          name: 'Video',
          component: () => import('../views/recvideo/children/Video.vue')
        }
      ]
    },
    // 每日推荐
    {
      path: '/receveryday',
      name: 'Receveryday',
      component: () => import('../views/receveryday/Receveryday.vue')
    },
    //我的收藏
    {
      path: '/myfavorite',
      name: 'Myfavorite',
      component: () => import('../views/myfavorite/myfavorite.vue')
    },

    //歌单详情
    {
      path: '/songlistdetail/:id',
      name: 'Songlistdetail',
      component: () => import('../views/songlistdetail/Songlistdetail.vue')
    },

    //歌手详情
    {
      path: "/singerdetail/:id",
      name: "Singerdetail",
      component: () => import('../views/singerdetail/Singerdetail.vue')
    },

    //专辑详情
    {
      path: '/albumdetail/:id',
      name: 'Albumdetail',
      component: () => import('../views/albumdetail/Albumdetail.vue')
    },

    //视频详情
    {
      path: '/videolistdetail/:id/:type',
      name: 'Videodetail',
      component: () => import('../views/videodetail/Videodetail.vue')
    },
    //用户个人主页
    {
      path: '/userdetail/:uid',
      name: 'UserDetail',
      component: () => import('../views/userdetail/Userdetail.vue')
    },

    //搜索结果页面
    {
      path: '/searchdetail/:keywords',
      name: 'Searchdetail',
      component: () => import('../views/searchdetail/Searchdetail.vue'),
      // redirect: "/searchdetail/songres/:keywords",   //参数会传递不了还是显示 keywords
      // redirect: to => {
      //   return { path: '/searchdetail/songres/', query: { keywords: to.params.keywords } }
      // },  //重定向到歌曲   内存溢出
      redirect: { name: 'SongRes' },  //成功
      children: [
        {
          path: '/searchdetail/songres/:keywords',
          name: 'SongRes',
          component: () => import('../views/searchdetail/children/SongRes.vue')
        },
        {
          path: '/searchdetail/albumres/:keywords',
          name: 'AlbumRes',
          component: () => import('../views/searchdetail/children/AlbumRes.vue')
        },
        {
          path: "/searchdetail/singerres/:keywords",
          name: "SingerRes",
          component: () => import('../views/searchdetail/children/SingerRes.vue'),
        },
        {
          path: "/searchdetail/songlistres/:keywords",
          name: "SongListRes",
          component: () => import('../views/searchdetail/children/SongListRes.vue'),
        },
        {
          path: "/searchdetail/mvres/:keywords",
          name: "MvRes",
          component: () => import('../views/searchdetail/children/MvRes.vue'),
        },
        {
          path: "/searchdetail/videores/:keywords",
          name: "VideoRes",
          component: () => import('../views/searchdetail/children/VideoRes.vue'),
        }, {
          path: '/searchdetail/userres/:keywords',
          name: 'UserRes',
          component: () => import('../views/searchdetail/children/UserRes.vue')
        }
      ]
    }

  ]
})

export default router
